#include "widget.h"
#include "ui_widget.h"
#include "gameselect.h"
#include <QDebug>
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QFont>
#include <QIcon>
#include <QSound>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //设置窗口标题和图标
    this->setWindowIcon(QIcon(":res/ico.png"));
    this->setWindowTitle("狂莽寻食");

    //对开始游戏按钮进行样式编写
    QFont  font("华文行楷",30);
    QPushButton* strartBtn = new QPushButton(this);
    strartBtn->move(this->width()*0.4,this->height()*0.65);
    strartBtn->setText("开始游戏");
    strartBtn->setFont(font);
    strartBtn->setStyleSheet(  "QPushButton {"
                               "border: 2px solid #8f8f91;"        // 设置边框
                               "border-radius: 15px;"              // 设置圆角半径
                               "background-color: #d1d1d1;"        // 设置背景颜色
                               "padding: 5px 10px;"                // 设置内边距
                               "}"
                               "QPushButton:hover {"
                               "background-color: #c0c0c0;"        // 设置鼠标悬停时的背景颜色
                               "}"
                               "QPushButton:pressed {"
                               "background-color: #a9a9a9;"        // 设置按钮按下时的背景颜色
                               "}");


    connect(strartBtn,&QPushButton::clicked,[=](){
       this->hide();
       QSound::play(":res/clicked.wav");
       Gameselect* gameselect = new Gameselect;
       gameselect->show();

            });


}

Widget::~Widget()
{
    delete ui;
}

void Widget::paintEvent(QPaintEvent *event)
{
    (void) event;
    QPixmap pix(":res/game_hall.png"); //


    QPainter painter(this); //


    painter.drawPixmap(0,0,this->width(),this->height(),pix); //


}

